package execd1126;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class Demo05Set {
    public static void main(String[] args) {
        Set<Stu> set = new HashSet<>();
        set.add(new Stu("0001"));
        set.add(new Stu("0001"));
        set.add(new Stu("0002"));
        set.add(new Stu("0003"));
        set.add(new Stu("0002"));
        set.add(new Stu("0004"));
        System.out.println(set);
    }


}
class Stu{
    private String sNo;

    public Stu() {
    }

    public Stu(String sNo) {
        this.sNo = sNo;
    }

    public String getsNo() {
        return sNo;
    }

    public void setsNo(String sNo) {
        this.sNo = sNo;
    }

    @Override
    public String toString() {
        return "Stu{" +
                "sNo='" + sNo + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Stu stu = (Stu) o;
        return Objects.equals(sNo, stu.sNo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sNo);
    }
}
